import { MockMethod } from "vite-plugin-mock";

// http://mockjs.com/examples.html#Object
const userInfo = [
  {
    name: "admin",
    role: ["admin"],
    menus: [
      {
        name: "bussiness",
        id: 1,
        children: [
          { name: "bussinessList", id: 11 },
          { name: "contractManagement", id: 12 }
        ]
      },
      {
        name: "user",
        id: 2,
        children: [{ name: "userList", id: 21 }]
      }
    ]
  },
  {
    name: "test",
    role: ["A"],
    menus: [
      {
        name: "bussiness",
        id: 1
      }
    ]
  }
];

const role = [
  { role: "A", name: "A", description: "some word" },
  { role: "B", name: "角色B", description: "some word for 角色B" }
];

const operates = [
  {
    name: "bussinessList",
    id: 11,
    children: [
      { name: "add", id: 111 },
      { name: "edit", id: 112 },
      { name: "del", id: 113 }
    ]
  },
  {
    name: "contractManagement",
    id: 12,
    children: [
      { name: "add", id: 121 },
      { name: "edit", id: 122 },
      { name: "del", id: 123 }
    ]
  },
  {
    name: "userList",
    id: 21,
    children: [
      { name: "add", id: 221 },
      { name: "edit", id: 222 },
      { name: "del", id: 223 }
    ]
  }
];

const ListOfUnionMember = {
  response_code: 200,
  response_msg: "SUCCESS",
  data: {
    total: "3",
    info: [
      {
        union_member_name: "华润置地",
        union_member_id: "hrzdjf0001",
        union: "华润通积分联盟",
        wallet_management: {
          wallet_address:
            "0x24c96919db634d1bb3b97489d66006d07a355075e4560059d3889c269b7bd82f",
          points_issued: "2000000",
          wallet_status: "正常",
          create_time: "2021-7-28 15:20:23"
        }
      },
      {
        union_member_name: "华润五丰",
        union_member_id: "hrzdjf0001",
        union: "华润通积分联盟",
        wallet_management: {
          wallet_address:
            "0x24c96936db634d1bb3b97489d66006d07a355075e4560059d3889c269b7yu83w",
          points_issued: "100000",
          wallet_status: "正常",
          create_time: "2021-7-28 15:20:23"
        }
      }
    ]
  }
};

const MemberList = {
  response_code: 200,
  response_msg: "SUCCESS",
  data: [
    {
      union_member_name: "华润置地",
      union_member_id: "hrzdjf0001"
    },
    {
      union_member_name: "华润五丰",
      union_member_id: "hrzdjf0002"
    },
    {
      union_member_name: "华润三九",
      union_member_id: "hrsjf0003"
    }
  ]
};

const changeStatusOfUnMember = {
  response_code: 200,
  response_msg: "SUCCESS",
  data: "03b827f7ba690fd6117878785a432db8a0fbb4b4d3679978a85ba30b79cd9d62"
};

export default [
  {
    url: "/login",
    method: "post",
    response: () => {
      return {
        code: 200,
        info: userInfo[0],
        accessToken: "eyJhbGciOiJIUzUxMiJ9.test111"
      };
    }
  },
  {
    url: "/role",
    method: "get",
    response: () => {
      return {
        code: 200,
        info: role[0]
      };
    }
  },
  {
    url: "/operatePermission",
    method: "post",
    response: () => {
      return {
        code: 200,
        info: operates[0]
      };
    }
  },
  {
    url: "/getBtnAuthByRouteName",
    method: "get",
    response: () => {
      // response: ({ query }) => {
      // if (query === "user") {
      //   return ["aaa", "fff", "add", "edit", "delete"];
      // } else {
      //   return [];
      // }
      return ["aaa", "fff", "add", "edit", "delete"];
    }
  },
  {
    url: "/getListOfUnionMember",
    method: "get",
    response: () => {
      return ListOfUnionMember;
    }
  },
  {
    url: "/dropDownListOfUM",
    method: "get",
    response: () => {
      return MemberList;
    }
  },
  {
    url: "/changeStatusOfUnMember",
    method: "post",
    response: () => {
      return changeStatusOfUnMember;
    }
  }
] as MockMethod[];
